<template>
  <div class="customer">
    <SideBar
      @current="setCurrent"
      @addUpdateTableList="addUpdateTableList"
    ></SideBar>
    <CustomerTable ref="CustomerTable"></CustomerTable>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Ref } from 'vue-property-decorator';
import SideBar from './components/SIdeBar.vue'
import CustomerTable from './components/customerTable.vue'
@Component({
  name: 'Customer',
  components: { SideBar, CustomerTable }
})
export default class Customer extends Vue {
  [x: string]: any
  @Ref() private readonly CustomerTable

  private async setCurrent (id) {
    this.CustomerTable.formData = {} // 清空自定义搜索
    await this.CustomerTable.getTableHeaders(id)
    this.CustomerTable.clearBatchSelect() // 清空批量选择 获取数据
    this.CustomerTable.getFilterConf(id) // 获取自定义搜索
  }

  private addUpdateTableList () {
    this.CustomerTable.handleSearchFunc()
  }

  private mounted () {
    this.$getCache('/server-crm/action/customer/common/panel/insert', ['customerInputConfig'], false, false, false, 'GET', false, 'data.fields') // 录入面板配置
    this.$getCache('/server-crm/action/customer/common/labels', ['customerAllLabels'], true, false, false, 'GET', false, 'data') // 客户标签
    this.$getCache('/base/action/general/cache/query', ['region'], false)
  }
}
</script>

<style lang="stylus" scoped>
.customer
  height 100%
  display flex
</style>
